package io.aicn.lowcode.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

@Data
@Schema(description = "Paginated response")
public class PageResponse<T> {
    
    @Schema(description = "List of items")
    private List<T> content;
    
    @Schema(description = "Total number of elements", example = "100")
    private Long totalElements;
    
    @Schema(description = "Total number of pages", example = "10")
    private Integer totalPages;
    
    @Schema(description = "Current page number", example = "1")
    private Integer currentPage;
    
    @Schema(description = "Page size", example = "10")
    private Integer pageSize;
    
    public PageResponse(List<T> content, Long totalElements, Integer currentPage, Integer pageSize) {
        this.content = content;
        this.totalElements = totalElements;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalPages = (int) Math.ceil((double) totalElements / pageSize);
    }
}